package top.fullj.bean;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.fullj.spi.Discover;

/**
 * @author bruce.wu
 * @since 2021/6/24 15:21
 */
public abstract class Json {

    private static final Logger LOG = LoggerFactory.getLogger(Json.class);

    private static final JsonCodec INSTANCE;

    static {
        INSTANCE = Discover.firstOr(JsonCodec.class, JacksonCodec::new);
        LOG.info("Load: {}", INSTANCE.getClass().getName());
    }

    public static String encode(Object value) {
        return INSTANCE.encode(value);
    }

    public static <T> T decode(String jsonStr, Class<T> type) {
        return INSTANCE.decode(jsonStr, type);
    }

}
